﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using HGZP.BLL;
using HGZP.Model;
using HGZP.PLL;
using Admin;
namespace SZCB.admin.FoodManager
{
    public partial class FoodList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                //删除流程
                if (Request.QueryString["Option"] == "Del")
                {
                    string _sGuid = Request.QueryString["Id"];
                    CFoodBLL myCFoodBLL = new CFoodBLL();
                    if (!string.IsNullOrEmpty(_sGuid))
                    {
                        if (myCFoodBLL.F_Delete(_sGuid))
                        {
                            Public.globalErrorString = "成功删除图书";
                        }
                        Tip_Web.Tip();
                    }
                }
                BindFoodClass();
                getCount();
                BindData();
            }

        }

        private void BindFoodClass()
        {
            CsFoodClassBLL myCsFoodClassBLL = new CsFoodClassBLL();
            ddlContentClass.DataSource = myCsFoodClassBLL.F02_SelectHaveWhere("");
            ddlContentClass.DataTextField = myCsFoodClassBLL.sName;
            ddlContentClass.DataValueField = myCsFoodClassBLL.sGuid;
            ddlContentClass.DataBind();
            ListItem listItem = new ListItem();
            listItem.Text = "----请选择分类----";
            listItem.Value = "0";
            ddlContentClass.Items.Add(listItem);
            ddlContentClass.SelectedValue = "0";
        }

        private void getCount()
        {
            string sql = "";
            CFoodBLL myCFoodBLL = new CFoodBLL();
            returnDataPager.RecordCount = myCFoodBLL.F09_GetCount(sql);
        }
        private void BindData()
        {
            string sql = "";
            CFoodBLL myCFoodBLL = new CFoodBLL();
            RptData.DataSource = myCFoodBLL.F08_SelectColumnHaveWhereOrder_OnePage(returnDataPager.StartRecordIndex - 1, returnDataPager.PageSize, "*", sql, myCFoodBLL.dCreateDate + " DESC");
            RptData.DataBind();
        }
        protected void returnDataPager_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }

        protected void ddlContentClass_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlContentClass.SelectedValue == "0")
                return;
        }

        protected void BtnSearch_Click(object sender, EventArgs e)
        {
         /*   string sql = "";
            if (!string.IsNullOrEmpty(txtName.Text))
                sql += " AND [sName] LIKE '%" + txtName.Text + "%'";
            if (!string.IsNullOrEmpty(txtAuthor.Text))
                sql += " AND [sNameBaseUserAuthor] LIKE '%" + txtAuthor.Text + "%'";
            if (ddlContentClass.SelectedValue != "0")
                sql += " AND [sGuidBaseBookContentClass]='" + ddlContentClass.SelectedValue + "'";
            if (ddlContentClassDetail.SelectedValue != "0")
                sql += " AND [sGuidBaseBookContentClassDetail]='" + ddlContentClassDetail.SelectedValue + "'";
            if (ddlStat.SelectedValue != "-99")
                sql += " AND [nStatus]='" + ddlStat.SelectedValue + "'";
            ViewState["wheresql"] = sql;
            getCount();
            BindData();*/
        }



    }
}